var t = getApp();

Page({
    data: {
        tab: "",
        testcolor: "#ffb32f",
        active: 0,
        isFixed: !1,
        child: !1
    },
    onLoad: function(a) {
        if (a.tab && this.setData({
            tab: a.tab
        }), a.mid && t._setMid(a.mid), a.scene) {
            var i = decodeURIComponent(a.scene);
            if (console.log(i), i) {
                var e = [];
                e = i.split("&");
                for (var o = 0; o < e.length; o++) {
                    var n;
                    n = e[o].split("="), console.log("59", n), "mid" == n[0] ? t._setMid(n[1]) : "tab" == n[0] ? this.setData({
                        tab: n[1]
                    }) : "child" == n[0] && this.setData({
                        child: !0
                    });
                }
            }
        }
        "child" == a.child && (console.log("111111111"), this.setData({
            child: !0
        })), this.getData();
        var s = wx.getSystemInfoSync().platform, c = this;
        setTimeout(function() {
            var t = wx.getMenuButtonBoundingClientRect().height;
            console.log(wx.getMenuButtonBoundingClientRect()), c.setData({
                viewHeight: "ios" == s ? t + 20 : t
            });
        }, 400);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), a = "";
        return t && (a = t), console.log("/packageI/cps/cpsExtension?tab=".concat(this.data.active, "&mid=").concat(a)), 
        {
            path: this.data.child ? "/packageI/cps/cpsExtension?tab=".concat(this.data.info[this.data.active].activity_id, "&mid=").concat(a, "&child=child") : "/packageI/cps/cpsExtension?tab=".concat(this.data.info[this.data.active].activity_id, "&mid=").concat(a)
        };
    },
    ascrollChange: function(t) {},
    toLink: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.web_url.mini_app_id, i = t.currentTarget.dataset.web_url.mini_path;
        wx.navigateToMiniProgram({
            appId: a,
            path: i,
            envVersion: "release",
            success: function(t) {}
        });
    },
    runGoPageYx: function(t) {
        for (var a = t.currentTarget.dataset.id, i = this.data.info, e = 0; e < i.length; e++) i[e].another_id == a && this.setData({
            active: e
        });
    },
    goPageYx: function(t) {
        for (var a = this.data.info, i = 0; i < a.length; i++) a[i].another_id == t && this.setData({
            active: i
        });
    },
    actChange: function(t) {
        console.log(t);
        var a = t.detail.index;
        this.setData({
            active: a
        }), console.log(this.data.info[a].activity_id), this.getPage(this.data.info[a].activity_id);
    },
    closePopup: function() {
        this.setData({
            show: !1
        });
    },
    imgPreview: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.img;
        wx.previewImage({
            current: a,
            urls: [ a ]
        });
    },
    getData: function() {
        var a = this, i = this, e = "";
        e = this.data.child ? "plugin.cps-sub-platform.frontend.plat-activity.getPlatList" : "plugin.aggregation-cps.api.plat-activity.getPlatList";
        var o = t.getNetAddresss(e);
        t._postNetWork({
            url: o,
            success: function(t) {
                var e = t.data;
                if (1 == e.result) {
                    i.setData({
                        info: e.data
                    });
                    var o = e.data[i.data.active].activity_id;
                    if (i.data.tab == o) console.log("这个tab是第一个"), a.getPage(o); else for (var n = 0; n < e.data.length; n++) i.data.tab == e.data[n].activity_id && i.goPageYx(e.data[n].another_id);
                    setTimeout(function() {
                        wx.createSelectorQuery().select(".navtab").boundingClientRect(function(t) {
                            console.log(t);
                            var a = t.height * (750 / t.width);
                            console.log(a), i.setData({
                                paddingHeight: a
                            });
                        }).exec();
                    }, 300);
                } else wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            }
        });
    },
    getPage: function(a) {
        var i = this;
        wx.showLoading({
            title: "加载中"
        });
        var e = "";
        e = this.data.child ? "plugin.cps-sub-platform.frontend.plat-activity.getPlatDetail" : "plugin.aggregation-cps.api.plat-activity.getPlatDetail";
        var o = t.getNetAddresss(e);
        t._postNetWork({
            url: o,
            data: {
                activity_id: a
            },
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    i.setData({
                        datas: a.data
                    });
                    var e, o = [];
                    for (var n in i.data.datas.page_setting.tab_image) n == a.data.another_id && (e = "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/cps/".concat(i.data.datas.page_setting.tab_image[n])), 
                    o.push(n);
                    i.setData({
                        buttonArr: o,
                        topImg: e
                    }), console.log(i.data.datas), wx.hideLoading({
                        success: function(t) {}
                    });
                } else wx.showToast({
                    title: a.msg,
                    duration: 1e3,
                    icon: "none"
                }), a.data.bind_mobile && i.setData({
                    show1: !0
                }), wx.hideLoading({
                    success: function(t) {}
                });
            }
        });
    },
    getShare: function() {
        var a = this;
        wx.showLoading({
            title: "海报加载中"
        });
        var i = "";
        i = this.data.child ? "plugin.cps-sub-platform.frontend.plat-activity.getPlatPoster" : "plugin.aggregation-cps.api.plat-activity.getPlatPoster";
        var e = t.getNetAddresss(i);
        t._postNetWork({
            url: e,
            data: {
                activity_id: this.data.info[this.data.active].activity_id,
                poster_type: 2
            },
            success: function(t) {
                var i = t.data;
                wx.hideLoading({
                    success: function(t) {}
                }), 1 == i.result ? a.setData({
                    show: !0,
                    shareImg: i.data.url
                }) : wx.showToast({
                    title: i.msg,
                    duration: 1e3,
                    icon: "none"
                });
            }
        });
    },
    tabrshowbtn: function(t) {
        t.detail && this.setData({
            kFootshow: !1
        });
    }
});